Skip to content

fix: Delay archive loading in Wayland to fix dialog positioning#385

Merged
max-lvs merged 3 commits intolinuxdeepin:release/eaglefrom
LiHua000:release/eagle
Apr 14, 2026
Merged

fix: Delay archive loading in Wayland to fix dialog positioning#385
max-lvs merged 3 commits intolinuxdeepin:release/eaglefrom
LiHua000:release/eagle

Conversation

@LiHua000
Copy link
Copy Markdown
Contributor

@LiHua000 LiHua000 commented Apr 14, 2026

Delay first archive loading by 200ms in Wayland to allow window positioning to complete before showing password dialogs. Prevents dialogs from appearing at (0,0) when opening encrypted archives.

Log: fix bug

Bug: https://pms.uniontech.com/bug-view-355681.html

Summary by Sourcery

Bug Fixes:

  • Ensure password dialogs for encrypted archives open at the correct window position on Wayland by deferring the first archive load.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Apr 14, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Delays the initial archive loading on Wayland by 200ms using a one‑time guard and QTimer to ensure password dialogs appear in the correct position instead of at (0,0).

Sequence diagram for delayed archive loading on Wayland

sequenceDiagram
    actor User
    participant MainWindow
    participant UiTools
    participant QTimer
    participant PasswordDialog

    alt Wayland_and_first_load
        User->>MainWindow: handleArguments_Open(listParam)
        MainWindow->>UiTools: isWayland()
        UiTools-->>MainWindow: true
        MainWindow->>QTimer: singleShot(200, callback)
        QTimer-->>MainWindow: timeout
        MainWindow->>MainWindow: loadArchive(listParam_0)
        MainWindow->>PasswordDialog: showPasswordDialog()
        PasswordDialog-->>User: Display_at_correct_position
    else Not_Wayland_or_not_first_load
        User->>MainWindow: handleArguments_Open(listParam)
        MainWindow->>UiTools: isWayland()
        UiTools-->>MainWindow: false_or_firstLoad_false
        MainWindow->>MainWindow: loadArchive(listParam_0)
        MainWindow->>PasswordDialog: showPasswordDialog()
        PasswordDialog-->>User: Display_immediately
    end
Loading

File-Level Changes

Change Details Files
Gate the first archive load on Wayland behind a one-time 200ms delayed QTimer callback to allow window positioning to settle before showing dialogs.
  • Introduce a static boolean flag to detect the first archive load invocation.
  • Check the Wayland environment and the first-load flag before loading the archive.
  • Use QTimer::singleShot with a 200ms delay to call loadArchive asynchronously on first load under Wayland.
  • Fallback to immediate loadArchive execution for non-Wayland platforms or subsequent loads.
src/source/mainwindow.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • The lambda passed to QTimer::singleShot captures listParam by reference, which can dangle after handleArguments_Open returns; capture the required value by copy instead (e.g., [this, file = listParam[0]]).
  • Using a function-static firstLoad flag may be surprising and is not thread-safe; consider making this a member variable or a more explicit startup-state mechanism tied to the window instance.
  • The 200ms delay is a magic number; consider defining a named constant or deriving the timing from an appropriate signal/event to make the intent clearer and behavior more robust across environments.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The lambda passed to QTimer::singleShot captures listParam by reference, which can dangle after handleArguments_Open returns; capture the required value by copy instead (e.g., [this, file = listParam[0]]).
- Using a function-static firstLoad flag may be surprising and is not thread-safe; consider making this a member variable or a more explicit startup-state mechanism tied to the window instance.
- The 200ms delay is a magic number; consider defining a named constant or deriving the timing from an appropriate signal/event to make the intent clearer and behavior more robust across environments.

## Individual Comments

### Comment 1
<location path="src/source/mainwindow.cpp" line_range="2598-2595" />
<code_context>
+    static bool firstLoad = true;
+    if (UiTools::isWayland() && firstLoad) {
+        firstLoad = false;
+        QTimer::singleShot(200, [this, &listParam]() {
+            loadArchive(listParam[0]);
+        });
+    } else {
</code_context>
<issue_to_address>
**issue (bug_risk):** Capturing `listParam` by reference in the delayed lambda risks a dangling reference.

Because the lambda runs 200 ms after `handleArguments_Open` returns, the const reference parameter `listParam` is already out of scope when accessed, leading to undefined behavior. Capture it safely instead, e.g. by value (`[this, listParam]`) or, more efficiently, capture just `listParam[0]` (`[this, path = listParam[0]]`) and use `path` inside the lambda.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread src/source/mainwindow.cpp
max-lvs
max-lvs previously approved these changes Apr 14, 2026
Delay first archive loading by 200ms in Wayland to allow window
positioning to complete before showing password dialogs. Prevents
dialogs from appearing at (0,0) when opening encrypted archives.

Log: fix bug

Bug: https://pms.uniontech.com/bug-view-355681.html
Display tar filename in progress when compressing tar.7z archives,
improving user experience by showing meaningful progress information.

压缩tar.7z时显示tar文件名,提升用户体验。

Log: tar.7z压缩时提示tar文件名
PMS: BUG-356753
Influence: 压缩tar.7z格式时,进度提示显示tar文件名,用户可以看到正在处理的归档文件名称
@LiHua000 LiHua000 force-pushed the release/eagle branch 3 times, most recently from fcc7bc8 to fd8b3c5 Compare April 14, 2026 11:46
@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: LiHua000, max-lvs

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@LiHua000
Copy link
Copy Markdown
Contributor Author

/merge

@max-lvs max-lvs merged commit b68c477 into linuxdeepin:release/eagle Apr 14, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants